package com.ly.repository;

import com.ly.entity.House;
import com.ly.entity.User;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

/**
 * user的DAO
 * @author ：LY
 * @date ：Created in 2020/11/7 19:14
 * @modified By：
 */
public interface UserRepository extends PagingAndSortingRepository<User,Long>, JpaSpecificationExecutor<User>{

    User findByName(String userName);

    User findUserByPhoneNumber(String telephone);

    @Modifying
    @Query("update User as user set user.name = :name where user.id = :id")
    void updateUsername(@Param(value = "id") Long id,@Param(value = "name")String name);

    @Modifying
    @Query("update User as user set user.email = :email where user.id = :id")
    void updateEmail(@Param(value = "id") Long id,@Param(value = "email")String email);
    @Modifying
    @Query("update User as user set user.password = :password where user.id = :id")
    void updatePassword(@Param(value = "id") Long id,@Param(value = "password")String password);

    @Modifying
    @Query("update User as user set user.status = :status where user.id = :id")
    void updateStatus(@Param(value = "id") Long id,@Param(value = "status")int status);
}
